package io.genezhao.mybatisplus;
/**
 * @author genezhao
 * @date 2018/1/2
 * @since
 */

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.util.StringUtils;

/**
 * <p>Description: </p>
 *
 * @author genezhao
 * @since
 */
public class BaseService<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> {

    protected Page<T> buildPage(Integer currentPage, Integer pageSize, String orderField) {
        if (ConstantPage.INIT_PAGE == currentPage) {
            throw new RuntimeException("page must from number 1");
        }
        if (null == pageSize) {
            pageSize = ConstantPage.PAGE_SIZE;
        }
        if (StringUtils.isEmpty(orderField)) {
//            orderField = "t1.update_time";
        }
        return new Page<>(currentPage, pageSize, orderField, false);
    }

}
